﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Configuration;
using System.Messaging;
using System.ServiceModel;
using GtsServer.Common;

namespace GtsServer.Service.WCF
{
    partial class SqlMsmqService : ServiceBase
    {
        ServiceHost host = null;
        public SqlMsmqService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                if (host != null)
                    host.Close();
                host = new ServiceHost(typeof(MsmqSqlService));
                host.Open();
                LogHelper.WriteLog("启动数据库msmq服务成功！");
                
            }
            catch (Exception e)
            {
                LogHelper.WriteLog("启动失败", e);
                host.Close();
            }
        }

        protected override void OnStop()
        {
            try
            {
                if (host != null)
                {
                    host.Close();
                    host = null;
                }
            }
            catch (Exception e)
            {
                LogHelper.WriteLog("停止失败", e);
            }
        }
    }
}
